package com.inibb.app.po.security;

import java.util.Collection;
import java.util.LinkedHashSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.inibb.app.po.IdEntity;







@Entity
@Table( name="ROLES" )
public class Role extends IdEntity {

	private String name;

	private String fixed;

	private String isDefault;

	@Column( name="IS_DEFAULT", length=1 )
	public String getIsDefault() {
		return isDefault;
	}

	public void setIsDefault(String isDefault) {
		this.isDefault = isDefault;
	}

	private Collection<Authority> auths = new LinkedHashSet<Authority>();

	@Column( name="NAME", length=20 )
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany( cascade = { CascadeType.PERSIST, CascadeType.MERGE } )
	@JoinTable(
			name = "ROLES_AUTHORITYS", 
			joinColumns = { @JoinColumn(name = "ROLE_ID") }, 
			inverseJoinColumns = { @JoinColumn(name = "AUTHORITY_ID") }
	)
	@OrderBy( "id" )
	public Collection<Authority> getAuths() {
		return auths;
	}

	public void setAuths(Collection<Authority> auths) {
		this.auths = auths;
	}

	@Column( name="FIXED", length=1 )
	public String getFixed() {
		return fixed;
	}

	public void setFixed(String fixed) {
		this.fixed = fixed;
	}
}
